import request from '@/config/axios'

// 软件附件 VO
export interface AttachmentVO {
  id: number // 编号
  baseInfoId: number // 所属软件
  type: string // 类型
  fileName: string // 文件名
  filePath: string // 文件路径
  dirId: string // 文件夹id
}

// 软件附件 API
export const AttachmentApi = {
  // 查询软件附件分页
  getAttachmentPage: async (params: any) => {
    return await request.get({ url: `/compo/attachment/page`, params })
  },

  // 查询软件附件详情
  getAttachment: async (id: number) => {
    return await request.get({ url: `/compo/attachment/get?id=` + id })
  },

  // 根据软件ID和附件类型查询附件列表
  listByBaseInfoIdAndType: async (baseInfoId: number, type: string) => {
    return await request.get<AttachmentVO[]>({ 
      url: `/compo/attachment/list-by-base-info-id-and-type`,
      params: { baseInfoId, type }
    })
  },

  // 新增软件附件
  createAttachment: async (data: AttachmentVO) => {
    return await request.post({ url: `/compo/attachment/create`, data })
  },

  // 修改软件附件
  updateAttachment: async (data: AttachmentVO) => {
    return await request.put({ url: `/compo/attachment/update`, data })
  },

  // 删除软件附件
  deleteAttachment: async (id: number) => {
    return await request.delete({ url: `/compo/attachment/delete?id=` + id })
  },

  // 导出软件附件 Excel
  exportAttachment: async (params) => {
    return await request.download({ url: `/compo/attachment/export-excel`, params })
  }
}